package com.chijun.mform.create.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.chijun.mform.R;
import com.chijun.mform.create.adapter.ShowProcessAdapter;
import com.chijun.mform.create.mode.FormApproveProcess;
import com.chijun.mform.create.mode.FormConfig;
import com.example.ccj.b.c.recycler.BaseRecycler;
import com.example.ccj.b.f.BaseFragment;
import com.example.ccj.u.GenerateId;

import java.util.List;

/**
 * 表单流程设置
 * @author 驰珺
 * whechat   : chijun9
 * create at : 2024/11/17 11:04
 */
public class FormAddProcessFragment extends BaseFragment  {

    public static final int FA_QI_REN_JIE_DIAN = 0;       //发起人节点编号
    public static final int SHEN_PI_REN_JIE_DIAN = 1;     //审批人节点编号
    public static final int CHAO_SONG_REN_JIE_DIAN = 2;   //抄送人节点编号
    public static final int APPROVAL_SELECT_MODE_ZHI_DING = 0;            //审批人选择模式：指定
    public static final int APPROVAL_SELECT_MODE_FA_QI_REN_ZI_JI = 1;     //审批人选择模式：发起人自己
    public static final int APPROVAL_SELECT_MODE_FA_QI_REN_XUAN_ZE = 2;   //审批人选择模式：发起人选择
    public static final int APPROVAL_MODE_YI_CI_SHEN_PI = 0;    //审批模式：依次审批
    public static final int APPROVAL_MODE_HUI_QIAN = 1;         //审批模式：会签
    public static final int APPROVAL_MODE_HUO_QIAN = 2;         //审批模式：或签
    public static final int APPROVAL_MODE_ZI_JI = 3;         //审批模式：自己
    public static final int OPERATION_PERMISSIONS_ONLY_READ = 0;  //表单字段操作权限 只读
    public static final int OPERATION_PERMISSIONS_CAN_WRITE = 1;  //表单字段操作权限 可编辑
    public static final int OPERATION_PERMISSIONS_HIDE = 2;       //表单字段操作权限 隐藏


    public static final int SHEN_PI_STATE_DENG_DAI = 0;         //审批状态：等待
    public static final int SHEN_PI_STATE_ZHENG_ZAI_SHEN = 1;   //审批状态：正在审批
    public static final int SHEN_PI_STATE_TONG_GUO = 2;         //审批状态：审批通过
    public static final int SHEN_PI_STATE_JU_JUE = 3;           //审批状态：审批拒绝
    public static final int SHEN_PI_STATE_ZHUAN_JIAO = 4;       //审批状态：转交
    public static final int SHEN_PI_STATE_PING_LUN = 5;       //审批状态：评论


    public static final int MODIFY_POWER_ = 0;                 //审批过程字段修改权限 正常不可修改
    public static final int MODIFY_POWER_HAVE = 1;             //审批过程字段修改权限 可修改
    public static final int MODIFY_POWER_HIDE = 2;             //审批过程字段修改权限 该字段对该流程内人员隐藏


    //指定审批人
    public static String ZD = "请选择审批人";
    //发起人自己
    public static String FQR = "发起人自己";
    //发起人自选
    public static String FQRS = "发起人自选";

    FormConfig formConfig;
    BaseRecycler<FormApproveProcess> baseRecycler;
    public FormAddProcessFragment(FormConfig formConfig){
        this.formConfig = formConfig;
    }


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_form_install_process,container,false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        //如果没有流程添加一个 发起人 流程
        List<FormApproveProcess> formApproveProcessList = formConfig.getFormApproveProcessList();
        if (formApproveProcessList.isEmpty()) {
            FormApproveProcess process = new FormApproveProcess();
            process.type = FA_QI_REN_JIE_DIAN;
            process.personType = APPROVAL_SELECT_MODE_FA_QI_REN_ZI_JI;
            process.id = GenerateId.getId();
            process.formId = formConfig.getForm().id;
            process.duoRenShenPiFangShi = APPROVAL_MODE_ZI_JI;
            process.name = "发起流程";
            formApproveProcessList.add(process);
        }

        baseRecycler = view.findViewById(R.id.fragment_form_install_process_rec);
        baseRecycler.setAdapter(formConfig.getFormApproveProcessList(),new ShowProcessAdapter(formConfig));
    }




}
